import * as RouteNames from '@/router/consts';
import router from '@/router';
import { store } from '@/store';
import { Plus } from '@element-plus/icons-vue';

// 指标平台
const IndexManage = {
  // 统计粒度
  [RouteNames.ROUTE_STATISTICS]: (to: any) => {
    store.commit('breadcrumb/setPathname', to.path);
    store.commit('breadcrumb/setRawPath', to);
    store.commit('breadcrumb/setFullPath', to.fullPath);
    store.commit('breadcrumb/setName', to.name);
    store.commit('breadcrumb/setShowReturn', false); //是否显示返回
    store.commit('breadcrumb/setAddonActions', [
      //
      {
        getAddon: () => {
          return (
            <el-button
              class="right-btn"
              type="primary"
              onClick={() =>
                store.commit('statistics/toggleDrawerVisible', true)
              }
            >
              <el-icon>
                <Plus />
              </el-icon>{' '}
              创建统计粒度
            </el-button>
          );
        }
      }
    ]);
  },
  // 维度列表
  [RouteNames.ROUTE_DIMENSIONMGMT]: (to: any) => {
    store.commit('breadcrumb/setPathname', to.path);
    store.commit('breadcrumb/setRawPath', to);
    store.commit('breadcrumb/setFullPath', to.fullPath);
    store.commit('breadcrumb/setName', to.name);
    store.commit('breadcrumb/setShowReturn', false); //是否显示返回
    // 返回
    store.commit('breadcrumb/setAddonActions', [
      //
      {
        getAddon: () => {
          return (
            <el-button
              class="right-btn"
              type="primary"
              onClick={() =>
                store.commit('dimension/toggleDrawerVisible', true)
              }
            >
              <el-icon>
                <Plus />
              </el-icon>{' '}
              创建维度
            </el-button>
          );
        }
      }
    ]);
  },
  // 模型列表
  [RouteNames.ROUTE_MODELMGMT]: (to: any) => {
    store.commit('breadcrumb/setPathname', to.path);
    store.commit('breadcrumb/setRawPath', to);
    store.commit('breadcrumb/setFullPath', to.fullPath);
    store.commit('breadcrumb/setName', to.name);
    store.commit('breadcrumb/setShowReturn', false); //是否显示返回

    store.commit('breadcrumb/setAddonActions', [
      //
      {
        getAddon: () => {
          return (
            <el-button
              class="right-btn"
              type="primary"
              onClick={() => {
                router.push('/index-manage/modeleCreate');
                store.commit('model/setModelId', undefined);
              }}
            >
              <el-icon>
                <Plus />
              </el-icon>{' '}
              创建模型
            </el-button>
          );
        }
      }
    ]);
  },
  // 模型编辑
  [RouteNames.ROUTE_MODELEDIT]: (to: any) => {
    store.commit('breadcrumb/setPathname', to.path);
    store.commit('breadcrumb/setRawPath', to);
    store.commit('breadcrumb/setFullPath', to.fullPath);
    store.commit('breadcrumb/setName', to.name);
    store.commit('breadcrumb/setShowReturn', true); //是否显示返回
    // 返回对象及返回动作
    store.commit('breadcrumb/setBackParams', {
      name: RouteNames.ROUTE_MODELMGMT
    });
    store.commit('breadcrumb/setAddonActions', [
      //
      {
        getAddon: () => {
          return <span></span>;
        }
      }
    ]);
  },

  // 模型新建
  [RouteNames.ROUTE_MODELCREATE]: (to: any) => {
    store.commit('breadcrumb/setPathname', to.path);
    store.commit('breadcrumb/setRawPath', to);
    store.commit('breadcrumb/setFullPath', to.fullPath);
    store.commit('breadcrumb/setName', to.name);
    store.commit('breadcrumb/setShowReturn', true); //是否显示返回
    // 返回对象及返回动作
    store.commit('breadcrumb/setBackParams', {
      name: RouteNames.ROUTE_MODELMGMT
    });
    store.commit('breadcrumb/setAddonActions', [
      //
      {
        getAddon: () => {
          return <span></span>;
        }
      }
    ]);
  },
  // 创建修饰词
  [RouteNames.ROUTE_MODIFER]: (to: any) => {
    store.commit('breadcrumb/setPathname', to.path);
    store.commit('breadcrumb/setRawPath', to);
    store.commit('breadcrumb/setFullPath', to.fullPath);
    store.commit('breadcrumb/setName', to.name);
    store.commit('breadcrumb/setShowReturn', false); //是否显示返回

    store.commit('breadcrumb/setAddonActions', [
      //
      {
        getAddon: () => {
          return (
            <el-button
              class="right-btn"
              type="primary"
              onClick={() => store.commit('modifier/toggleDrawerVisible', true)}
            >
              <el-icon>
                <Plus />
              </el-icon>{' '}
              创建修饰词
            </el-button>
          );
        }
      }
    ]);
  }
};

export default IndexManage;
